import { ProjectStorage } from '/@/storage/ProjectStorage.ts';
import { Config } from '/@/config/Config.ts';

/**
 * 统一存储接口
 */
export interface StorageInterface {
  get: (key: string) => any
  set: (key: string, value: any) => void
  has: (key: string) => boolean
  /**
   * 获取存储对象的原始实例
   */
  getOriginalObject: () => any
}

/**
 * 存储统一控制器
 */
export class CommonStorage {
  static instance: StorageInterface
  static {
    // 根据配置文件中的存储位置，创建对应的存储实例对象
    switch (Config.storage.commonStorageLocate) {
      case 'PROJECT':
        CommonStorage.instance = new ProjectStorage()
        break
      default:
        throw new Error('暂不支持该类型存储：' + Config.storage.commonStorageLocate)
    }
  }
}
